<?php
/**
 * | @author 韩威兵^life <1877361302@qq.com>
 * +----------------------------------------------------------------------
 * | @copyright 2016 - 2019 HQ
 * +----------------------------------------------------------------------
 * | @version $Id: 2019/4/25 15:03 jiahe_new base.php 韩威兵^life $
 * +----------------------------------------------------------------------
 */

namespace app\api\controller;

use think\Controller;
use think\Log;
use app\common\common\Server\commonServer;

class  Base extends Controller {
    /**
     * 自动加载
     */
    public function _initialize(){
        $this->init();
        $data = input();
        $log_data['REQUEST_METHOD'] = $_SERVER['REQUEST_METHOD'];
        $log_data['ip'] = get_client_ip();
        $log_data['api_input'] = $data;
        Log::record($log_data,'appletInput');
        $this->webStatusParent();
    }

    /**
     * 默认启动项目
     */
    public function init(){
        if(config('app_debug') == true){
            error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
        }else{
            error_reporting(E_ERROR);
        }
    }

    /**
     * 查看是否是维护时间
     */
    public function webStatusParent()
    {
        $stop_start_time = getRedis(7)->get('jhyp:wxdc:yingye:StartStopTime');
        $stop_end_time   = getRedis(7)->get('jhyp:wxdc:yingye:EndStopTime');


        if (!empty($stop_start_time) && !empty($stop_end_time)) {
            $data['msg']   = '嘉和一品粥点餐厅”将于'.$stop_start_time.'-'.$stop_end_time.'对所有门店进行维护升级，敬请谅解。';
            //$data['start'] = $stop_start_time;
            //$data['end']   = $stop_end_time;

            $data['start'] = date('m月d日 H:i', strtotime($stop_start_time));
            $data['end']   = date('m月d日 H:i', strtotime($stop_end_time));;

            commonServer::error(99998, $data)->exits();
        }
    }





}  